<extend name="./Application/Common/View/block/base.php" />
<block name="header">
    <include file="./Application/Admin/View/block/easyui_header.php" />
    <link href="__PUBLIC__/css/Content/index.css" rel="stylesheet" type="text/css" />
    <style>
        #dg{
            height: 100%;;
        }
    </style>
</block>
<block name="bdoy">
    <body>
    <table id="dg"></table>

    <div id="toolbar" style="padding:5px;height:auto">
        <div style="margin-bottom:5px">
            <!--            <a href="#" id="add_button" class="easyui-linkbutton" iconCls="icon-add" plain="true">{:LANG('add')}</a>-->
            <!--            <a href="#" id="edit_button" class="easyui-linkbutton" iconCls="icon-edit" plain="true">{:LANG('edit')}</a>-->
            <!--            <a href="#" id="del_button" class="easyui-linkbutton" iconCls="icon-remove" plain="true">{:LANG('del')}</a>-->
            <a href="#" id="search_button" class="easyui-linkbutton" iconCls="icon-search" plain="true">{:LANG('search')}</a>
            <a href="#" id="reload_button" class="easyui-linkbutton" iconCls="icon-reload" plain="true">{:LANG('reload')}</a>
            <!--            <a href="#" id="clear_button" class="easyui-linkbutton" iconCls="icon-redo" plain="true">{:LANG('clearSelections')}</a>-->
        </div>
        <div id="queryMaterialsRemovalParamZone">
            <fieldset>
                <legend>按设施查找</legend>
                <form id="query_form_one" method="post" action="">
                    <table>
                        <tr>
                            <td>设施名称：</td>
                            <td>
                                <input type="text" name="signposition"/>
                            </td>
                            <td>从：</td>
                            <td><input class="easyui-datebox" name="start" style="width: 100px;"></td>
                            <td>到：</td>
                            <td><input class="easyui-datebox" name="end" style="width: 100px;"></td>
                            <td><a id="query_button_one" href="#" class="easyui-linkbutton" iconCls="icon-search">查询</a></td>
                            <td><a href="#" class="easyui-linkbutton" iconCls="icon-undo" onclick="javascript:$('#query_form_one').form('clear');">重置</a></td>
                        </tr>
                    </table>
                </form>
            </fieldset>
            <fieldset>
                <legend>按人员查找</legend>
                <form id="query_form" method="post" action="">
                    <table>
                        <tr>
                            <td>姓名：</td>
                            <td>
                                <select class="easyui-combobox" name="uid" style="width:100px;">
                                    <option value=""></option>
                                    <volist name="admins" id="p">
                                        <option value="{$p['id']}">{$p['realname']}</option>
                                    </volist>
                                </select>
                            </td>
                            <td>从：</td>
                            <td><input class="easyui-datebox" name="start" style="width: 100px;"></td>
                            <td>到：</td>
                            <td><input class="easyui-datebox" name="end" style="width: 100px;"></td>
                            <td><a id="query_button" href="#" class="easyui-linkbutton" iconCls="icon-search">查询</a></td>
                            <td><a href="#" class="easyui-linkbutton" iconCls="icon-undo" onclick="javascript:$('#query_form').form('clear');">重置</a></td>
                        </tr>
                    </table>
                </form>
            </fieldset>

        </div>
    </div>
    <div id="gps_window" class="easyui-window" title="打卡信息查看" data-options="closed:true,modal:true" style="width:900px;height:500px;overflow: hidden">
        <iframe id="gps_fream" style="width:900px;height:500px;"></iframe>
    </div>
    <include file="./Application/Admin/View/block/easyui_window.php" />
    </body>
</block>
<block name="footExtendJs">
    <script type="text/javascript">

        $(function(){
                var request_url = '__URL__/get_all_reg_log';
                jQuery('#dg').datagrid({
                    fit:true,
                    nowrap: false,
                    striped: true,
                    collapsible:false,
                    url:request_url,
//                queryParams:{page:1,rows:20},
                    method:'get',
                    pageNumber:1,
                    pageSize:{:get_kv_val('admin_page_list_num')},
            pageList:[{:get_kv_val('admin_page_list_num')},50,100,200],
            idField:'id',
                remoteSort: false,
                columns:[[
                {field:'realname',title:'姓名', width:120,align:'center'},
                {field:'phone',title:'个人电话', width:120,align:'center'},
                {field:'status_text',title:'打卡状态', width:150,align:'center'},
                {field:'createtime',title:'打卡时间', width:150,align:'center'},
                {field:'work_time',title:'上班时长(小时)', width:150,align:'center'},
//                {field:'address',title:'打卡地点', width:150,align:'center'},
                {field:'signposition',title:'所属设施', width:150,align:'center'},
                {field:'point',title:'打卡坐标<br>(双击坐标可在地图查看)', width:150,align:'center'},
                {field:'photo',title:'打卡照片', width:150,align:'center'},
            ]],
            pagination:true,
            rownumbers:true,
            singleSelect:false,
            toolbar: '#toolbar',
            rowStyler: function(index,row){
                if (row.status < 0){
                    return 'background:rgba(255, 133, 133, 1);;color:#ffffff;';
                }
            },
            onDblClickRow: function(rowIndex, rowData){
                var open_url = '__URL__/show_on_map?gps='+rowData.point+'&uid='+rowData.uid+'&id='+rowData.id;
                $('#gps_fream').attr('src', open_url);
                $('#gps_window').window('open');
            },
        });
        //按钮事件绑定
        $('#add_button').click(function(){
            open_window(add_title, '__URL__/add');
        });
        $('#edit_button').click(function(){
            var id = jQuery('#dg').datagrid('getSelected');
            if(!id){
                msgShow('{:LANG('tips')}', '{:LANG('pls_slet_row')}', 'warning');
            }
            open_window('edit_title', '__URL__/edit?id='+id.id);
        });
        $('#del_button').click(function(){
            var id = jQuery('#dg').datagrid('getSelected');
            if(!id){
                msgShow('{:LANG('tips')}', '{:LANG('pls_slet_row')}', 'warning');
            }
            var ids = jQuery('#dg').datagrid('getSelections');
            var s = '';
            for(var i=0;i<ids.length;i++){
                s += ids[i].id+',';
            }

            $.post("__URL__/deleteArray",{"ids":s}, function(result){
                console.log(result);
                if(result == 1){
                    flowShow('{:LANG('tips')}', '{:LANG('delete_success')}');
                } else if(result == 0){
                    msgShow('{:LANG('tips')}', '{:LANG('delete_error')}', 'error');
                }

            });
        });
        $('#search_button').click(function(){
            $('#queryMaterialsRemovalParamZone').toggle();
            $('#dg').datagrid("resize");
        });
        $('#reload_button').click(function(){
            $('#dg').datagrid('load', {});
//                window.location.href = window.location.href;
        });
        $('#reload_clear').click(function(){
            $('#dg').datagrid('clearSelections');
        });

        $('#query_button').click(function(){
            var obj = $('#query_form').serializeJson();
            $('#dg').datagrid('load',obj);
        });
        $('#query_button_one').click(function(){
            var obj = $('#query_form_one').serializeJson();
            $('#dg').datagrid('load',obj);
        });
        });
        $('#queryMaterialsRemovalParamZone').hide();
        $('#sheshi').combobox({
            onChange: function (newValue, oldValue) {
                if(newValue==1){
                    $('#sheshi_id').combobox('reload','/Manage/AdminPumpStation/get_all_combox');
                }
                if(newValue==2){
                    $('#sheshi_id').combobox('reload','/Manage/AdminCsdt/get_all_combox');
                }
                if(newValue==3){
                    $('#sheshi_id').combobox('reload','/Manage/AdminGate/get_all_combox');
                }
            }
        });

    </script>
</block>
